package com.hackafone.storytail;

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import com.hackafone.storytail.R;
import com.hackafone.storytail.model.Tale;
import com.hackafone.storytail.service.StoryTailServices;
import com.hackafone.storytail.service.StoryTailServices.TaleList;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.telephony.ServiceState;

public class StoryTailActivity extends MapActivity
{
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		MapView mapView = (MapView) findViewById(R.id.mapview);
	    mapView.setBuiltInZoomControls(true);
	    
	    
		TaleList tl = StoryTailServices.getTales();
		
		List<Overlay> mapOverlays = mapView.getOverlays();
		Drawable drawable = this.getResources().getDrawable(android.R.drawable.star_on);
		TailItemizedOverlay itemizedoverlay = new TailItemizedOverlay(drawable, this);
		GeoPoint point;
		OverlayItem overlayitem ;
		
		for (Tale tale : tl.getTale())
		{
			point = new GeoPoint((int)(tale.getLastLat()  * 1e6), (int)(tale.getLastLon()* 1e6));
			overlayitem = new OverlayItem(point, "Story Tail", tale.getTitle());
			itemizedoverlay.addOverlay(overlayitem);
		}
		
		mapOverlays.add(itemizedoverlay);
	}

	@Override
	protected boolean isRouteDisplayed()
	{
		// TODO Auto-generated method stub
		return false;
	}
}